﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ECMS.AppService.Interfaces;
using ECMS.Infrastructure.Const;
using ECMS.Infrastructure.Helper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ECMS.Api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class CommonController : ControllerBase
    {
        private IAppUserService _service;
        public CommonController(IAppUserService service)
        {
            _service = service;
        }
        /// <summary>
        /// 图片验证码
        /// </summary>
        /// <param name="_vierificationCodeServices"></param>
        /// <returns></returns>
        [HttpGet("YZM")]
        public IActionResult ValidateCode([FromServices]VierificationCodeHelper _vierificationCodeServices)
        {
            string code = "";
            System.IO.MemoryStream ms = _vierificationCodeServices.Create(out code);
            HttpContext.Session.SetString(Const.APPUSERSESSIONCOED, code);
            Response.Body.Dispose();
            return File(ms.ToArray(), @"image/png");
        }
    }
}